package ge.modules.ia;

import java.util.HashMap;

public class StateMachineBaseEntity 
{
	private static StateMachineBaseEntity instance;
	 
	private HashMap<Integer, StateMachineModule<?> > entities;
	
	private StateMachineBaseEntity()
	{
		entities = new HashMap<Integer,StateMachineModule<?>>();
	}
	
	
	public static StateMachineBaseEntity get()
	{
		if(instance == null)
			instance = new StateMachineBaseEntity();
		
		return instance;
	}
	/**
	 * Subscribes a StateMachine for the event dispatcher
	 * @param id Id of the machine
	 * @param owner Owner of the machine
	 */
	public void suscribe(int id, StateMachineModule<?> owner)
	{
		entities.put(id, owner);
	}
	/**
	 * 	Returns the actor associated to that id
	 * @param id Id of the state machine of the actor
	 * @return  The StateMachine<?>, or Null if there isn't one
	 */
	public StateMachineModule<?> getEntity(int id)
	{
		return entities.get(id);
	}
	
	/**
	 * Removes the entity
	 * @param id  Id of the state machine
	 * @return StateMachine<? eliminated, NULL if it doesn't exist
	 */
	public StateMachineModule<?> remove(int id)
	{
		return entities.remove(id);
	}
	
	
}
